package com.laibatour.generator.entity;

import com.laibatour.generator.utils.GeneratorUtil;
import com.laibatour.generator.utils.PropertieUtils;
import org.apache.commons.lang.StringUtils;

import java.util.List;


public class Table {

	private String pack = PropertieUtils.getProperty("package");

	private String tableName;

	private String entityNameZH;

	private List<Field> fields;

    private boolean hasTime;

    private boolean hasMath;

    public String getPack() {
        return pack;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getEntityName() {
        return StringUtils.capitalize(GeneratorUtil.replace(getTableName()));
    }

    public String getEntityNameZH() {
        return entityNameZH;
    }

    public void setEntityNameZH(String entityNameZH) {
        this.entityNameZH = entityNameZH;
    }

    public List<Field> getFields() {
        return fields;
    }

    public void setFields(List<Field> fields) {
        this.fields = fields;
    }

    public boolean isHasTime() {
        return hasTime;
    }

    public void setHasTime(boolean hasTime) {
        this.hasTime = hasTime;
    }

    public boolean isHasMath() {
        return hasMath;
    }

    public void setHasMath(boolean hasMath) {
        this.hasMath = hasMath;
    }

    public boolean hasField(String fieldName) {
        for (Field field : fields) {
            if (field.getName().equalsIgnoreCase(fieldName)) {
                return true;
            }
        }
        return false;
    }
}
